﻿// Test_ForUPnp.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//
#include <Windows.h>
#include <tchar.h>
#include <list>
using namespace std;
#include "../../../../NetEngine_Windows/NetEngine_SourceCode/XyRyNet_CommHdr.h"
#include "../../../../NetEngine_Windows/NetEngine_SourceCode/NetEngine_RfcComponents/RfcComponents_UPnpProtocol/UPnpProtocol_Define.h"
#include "../../../../NetEngine_Windows/NetEngine_SourceCode/NetEngine_RfcComponents/RfcComponents_UPnpProtocol/UPnpProtocol_Error.h"

#pragma comment(lib,"Ws2_32.lib")
#pragma comment(lib,"../../../../NetEngine_Windows/NetEngine_SourceCode/Debug/RfcComponents_UPnpProtocol.lib")

int main()
{
	WSADATA st_WSAData;
	WSAStartup(MAKEWORD(2, 2), &st_WSAData);

	int nCount = 0;
	XNETHANDLE xhToken;
	UPNPPROTOCOL_DEVICEINFO st_DeviceInfo;

	memset(&st_DeviceInfo, '\0', sizeof(UPNPPROTOCOL_DEVICEINFO));

	UPnpProtocol_Client_Create(&xhToken);
	UPnpProtocol_Client_MSearch(xhToken);
	UPnpProtocol_Client_GetCount(xhToken, &nCount);
	UPnpProtocol_Client_GetDeviceInfo(xhToken,&st_DeviceInfo);
	UPnpProtocol_Client_GetCtrlInfo(xhToken);

	TCHAR tszIPAddr[64];
	memset(tszIPAddr, '\0', sizeof(tszIPAddr));
	UPnpProtocol_Client_GetExternalIPAddress(xhToken, tszIPAddr);
	UPnpProtocol_Client_Close(xhToken);
	WSACleanup();
	return 0;
}